<?php defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.tooltip'); 
JHTML::_('behavior.formvalidation');
$document =& JFactory::getDocument();
$lang =& JFactory::getLanguage();
$row=$this->Product;
$document->setTitle( $row->name );
$document->setDescription( 'Properties, '.$row->name.' : '.$row->name.' en '.$row->name.' : '.$row->nombre_provincia );
$document->setMetadata('keywords', 'properties, '.str_replace(' ',', ',$row->name_category).' , '.$row->name.' , '.$row->name_locality.' , '.$row->name_state);

$component = JComponentHelper::getComponent( 'com_properties' );
$params = new JParameter( $component->params );
$ActivarDescripcion=$params->get('ActivarDescripcion');
$ActivarDetails=$params->get('ActivarDetails');
$ActivarContactar=$params->get('ActivarContactar');
$ActivarReservas=$params->get('ActivarReservas');
$ActivarMapa=$params->get('ActivarMapa');
$ActivarTabs=$params->get('ActivarTabs');
$ActivarPanoramica=$params->get('ActivarPanoramica');
$SimbolPrice=$params->get('SimbolPrice');
$PositionPrice=$params->get('PositionPrice');
$currencyformat=$params->get('FormatPrice');

if(!JRequest::getVar('Itemid')){$Itemid = 0;}
else{$Itemid = JRequest::getVar('Itemid');}

$view = JRequest::getVar('view');

$id = JRequest::getVar('id');
$cid = JRequest::getVar('cid', 0, '', 'int');
$tid = JRequest::getVar('tid', 0, '', 'int');

//echo 'cid: '.$cid.' tid: '.$tid.' id: '.$id.' view: '.$view.'<br>';

if($ActivarTabs == 1){
jimport('joomla.html.pane');
$pane =& JPane::getInstance('tabs', array('startOffset'=>0)); 
echo $pane->startPane( 'pane' );


if($ActivarDescripcion == 1){
echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Description').'" title="'.JText::_('Description').'" src="components/com_properties/includes/img/detalles.png" />', 'panel1' );

echo $row->description2;

echo $pane->endPanel();
}
}
if($ActivarTabs == 1){
if($ActivarDetails == 1){
echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Detail').'" title="'.JText::_('Detail').'" src="components/com_properties/includes/img/description.png" />', 'panel1' );


?>	 
<div class="tituloProduct" style="float:left; width:100%;"></div>
<div class="detalleProduct" style="width:48%; float:left; margin:0px !important;">
<?php
if($row->price!=0){
$number = $row->price;
		if ($currencyformat==0) {
			$formatted_price = number_format($number);
		} else if ($currencyformat==1) {
			$formatted_price = number_format($number, 2,".",",");
		} else if ($currencyformat==2) {
			$formatted_price = number_format($number, 0,",",".");
		} else if ($currencyformat==3) {			
			$formatted_price = number_format($number, 2,",",".");
		}
if($PositionPrice==0){
echo JText::_('Price'); ?>: <?php echo $SimbolPrice.' '. $formatted_price; 
}else{
echo JText::_('Price'); ?>: <?php echo $formatted_price .' '. $SimbolPrice;
}
echo '<br />';
}
?>



<?php
/*
if($row->extra11!=0){
$number = $row->extra11;
		if ($currencyformat==0) {
			$formatted_price = number_format($number);
		} else if ($currencyformat==1) {
			$formatted_price = number_format($number, 2,".",",");
		} else if ($currencyformat==2) {
			$formatted_price = number_format($number, 0,",",".");
		} else if ($currencyformat==3) {			
			$formatted_price = number_format($number, 2,",",".");
		}
if($PositionPrice==0){
echo JText::_('Price extra11'); ?>: <?php echo $SimbolPrice.' '. $formatted_price; 
}else{
echo JText::_('Price extra11'); ?>: <?php echo $formatted_price .' '. $SimbolPrice;
}
echo '<br />';
}
*/
?>

<?php
/*
if($row->extra12!=0){
$number = $row->extra11;
		if ($currencyformat==0) {
			$formatted_price = number_format($number);
		} else if ($currencyformat==1) {
			$formatted_price = number_format($number, 2,".",",");
		} else if ($currencyformat==2) {
			$formatted_price = number_format($number, 0,",",".");
		} else if ($currencyformat==3) {			
			$formatted_price = number_format($number, 2,",",".");
		}
if($PositionPrice==0){
echo JText::_('Price extra12'); ?>: <?php echo $SimbolPrice.' '. $formatted_price; 
}else{
echo JText::_('Price extra12'); ?>: <?php echo $formatted_price .' '. $SimbolPrice;
}
echo '<br />';
}
*/
?>



<?php if($row->adress){echo JText::_('Adress') .' : '. $row->adress.'<br />';} ?>
<?php if($row->years){echo JText::_('Years') .' : '. $row->years.'<br />';} ?>
<?php if($row->bedrooms){echo JText::_('Bedrooms') .' : '. $row->bedrooms.'<br />';} ?>
<?php if($row->bathrooms){echo JText::_('Bathrooms') .' : '. $row->bathrooms.'<br />';} ?>
<?php if($row->garage){echo JText::_('Garage') .' : '. $row->garage.'<br />';} ?>
<?php if($row->area){echo JText::_('Total Area') .' : '. $row->area.' '.JText::sprintf('Simbol Metric').'<br />';} ?>
<?php if($row->covered_area){echo JText::_('Covered Area') .' : '. $row->covered_area.' '.JText::sprintf('Simbol Metric').'<br />';} ?>
<?php if($row->available){echo JText::_('DETAILS MARKET').' : '.JText::_('DETAILS_MARKET'.$row->available).'<br />';} ?>

<?php if($row->extra1){echo JText::_('extra1') .'<br />';} ?>
<?php if($row->extra2){echo JText::_('extra2') .'<br />';} ?>
<?php if($row->extra3){echo JText::_('extra3') .'<br />';} ?>
<?php if($row->extra4){echo JText::_('extra4') .'<br />';} ?>
<?php if($row->extra5){echo JText::_('extra5') .'<br />';} ?>
<?php if($row->extra6){echo JText::_('extra6') .'<br />';} ?>
<?php if($row->extra7){echo JText::_('extra7') .'<br />';} ?>
<?php if($row->extra8){echo JText::_('extra8') .'<br />';} ?>
<?php if($row->extra9){echo JText::_('extra9') .'<br />';} ?>
<?php if($row->extra10){echo JText::_('extra10') .'<br />';} ?>



</div>
<div class="detalleProduct" style="width:48%; float:left; margin:0px;">
<?php echo $row->description; ?><br />
<?php $ruta= JURI::base().'index.php?option=com_properties&view=property&task=recommend&tmpl=component&id='.$row->id;
?>
<a onclick="void window.open('<?php echo JRoute::_( $ruta );?>', '_blank', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no,screenX=100,screenY=200');return false;" href=""><?php echo JText::_('Send to a friend');?></a>
</div>	
 <div style="clear:both"></div>
<?php

echo $pane->endPanel();

}
}
if($ActivarTabs == 1){

echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Images').'" title="'.JText::_('Images').'" src="components/com_properties/includes/img/foto.png" />', 'panel2' );
}
$watermark=JText::_('DETAILS_MARKET'.$row->available).'-'.$lang->getTag().'.png';
?>

<div class="tituloProduct" style="float:left; width:100%;"></div>
<div id="slideshow">
	<div id="previewPane">
		<div align="center">
				<div id="watermark_box">
<img src="images/properties/<?php echo $row->image1;?>" alt="<?php echo $row->image1desc;?>" width="460" >
		<span style="display: none;" id="waitMessage">
<img src="images/properties/tools/loading.gif" alt=""></span>	
<?php if($row->disponible_Product!=0){?>
<img src="images/properties/tools/<?php echo $disponible; ?>.png" class="watermark" alt="">
<?php }?>			</div>
							
					</div>
		<div id="largeImageCaption"><?php echo $row->image1desc; ?></div>

	</div>
	<div id="galleryContainer">
		<div id="theImages">

	
<?php
$imageCaption='';
 if($row->image1){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image1;?>','1');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image1;?>" alt="222"/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image1desc.'</div>'; }?>	
<?php if($row->image2){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image2;?>','2');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image2;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image2desc.'</div>'; }?>
<?php if($row->image3){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image3;?>','3');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image3;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image3desc.'</div>'; }?>	
<?php if($row->image4){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image4;?>','4');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image4;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image4desc.'</div>'; }?>
<?php if($row->image5){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image5;?>','5');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image5;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image5desc.'</div>'; }?>
<?php if($row->image6){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image6;?>','6');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image6;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image6desc.'</div>'; }?>
<?php if($row->image7){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image7;?>','7');return false"><img style="opacity: 1;" src="images/properties/peques/peque_<?php echo $row->image7;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image7desc.'</div>'; }?>	
<?php if($row->image8){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image8;?>','8');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image8;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image8desc.'</div>'; }?>
<?php if($row->image9){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image9;?>','9');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image9;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image9desc.'</div>'; }?>	
<?php if($row->image10){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image10;?>','10');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image10;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image10desc.'</div>'; }?>
<?php if($row->image11){?>
				<a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image11;?>','11');return false"><img src="images/properties/peques/peque_<?php echo $row->image11;?>" alt=""/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image11desc.'</div>'; }?>		
<?php if($row->image12){?>
                <a href="#" onclick="showPreview('<?php echo JURI::base();?>images/properties/<?php echo $row->image12;?>','12');return false"><img style="opacity: 0.75;" src="images/properties/peques/peque_<?php echo $row->image12;?>" alt="111"/></a>
<?php $imageCaption.='<div class="imageCaption">'.$row->image12desc.'</div>'; }?>
				<!-- End thumbnails -->			

		
				<!-- Image captions imageCaption-->	
<?php echo $imageCaption;?>					
				<!-- End image captions -->




				<div id="slideEnd"></div>
		</div>

	</div>
</div>
<div style="clear: both;"></div>

<!--END IMAGE TABLE-->	




<?php 
if($ActivarPanoramica == 1){
if($ActivarTabs == 1){
echo $pane->endPanel();
echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Panoramic').'" title="'.JText::_('Panoramic').'" src="components/com_properties/includes/img/panoramica.png" />', 'panel2' );
}
$caption = $row->titulo_Product;

$destino_panoramica1 = JURI::base().'images/properties/panoramics/'.$row->panoramic;
?>        	
<?php echo"
<script type=\"text/javascript\" >
			window.addEvent('load', init);			
			function init() {
				var myPamoo = new pamoorama('pamoorama1', {width: 480, footercolor: '#fff', captioncolor: '#000', caption: '$caption'});
					}
		</script>
<div class=\"tituloProduct\" style=\"float: left; width: 100%;\"></div>	
<center><div style=\"width: 500px;\" id=\"pamoorama1\" alt=\"$destino_panoramica1\"></div></center>";
?>
<?php 
}/*Final if ActivarPanoramica*/
if($ActivarContactar == 1){
if($ActivarTabs == 1){
echo $pane->endPanel();
echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Contact').'" title="'.JText::_('Contact').'" src="components/com_properties/includes/img/contactar.png" />', 'panel3' );
}
?>

<div id="contactarporestapropiedad">
<script type="text/javascript">
<!--
	Window.onDomReady(function(){
		document.formvalidator.setHandler('passverify', function (value) { return ($('password').value == value); }	);
	});
// -->
</script>

<?php
	if(isset($this->message)){
		$this->display('message');
	}
//echo 'msg : '.$this->msg;

	//index.php?option=com_properties&view=property&catid='.$row->catslug.'&id='.$row->slug
?>

<form action="<?php echo JRoute::_( 'index.php' ); ?>" method="post" id="josForm2" name="josForm2" class="form-validate">
<input type="hidden" name="linkid" value="<?php echo JRequest::getVar('id'); ?>" />
<input type="hidden" name="linkcid" value="<?php echo JRequest::getVar('cid'); ?>" />
<input type="hidden" name="linktid" value="<?php echo JRequest::getVar('tid'); ?>" />
<input type="hidden" name="subject" value="<?php echo JRequest::getVar('id'); ?>" />

<div class="componentheading"><?php echo JText::_( 'Contact for Property' ); ?></div>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">
<tr>
	<td width="30%">
		<label id="namemsg" for="name"><?php echo JText::_( 'Name' ); ?>: </label>
	</td>
  	<td><input type="text" name="name" id="name" size="40" value="<?php //echo $this->user->get( 'name' );?>" class="inputbox required" maxlength="50" style="width:295px;" /></td>
</tr>
<tr>
	<td height="40">
		<label id="emailmsg" for="email"><?php echo JText::_( 'Email' ); ?>: </label>
	</td>
	<td><input type="text" id="email" name="email" size="40" value="<?php //echo //$this->user->get( 'email' );?>" class="inputbox required validate-email" maxlength="100" style="width:295px;" /></td>
</tr>

<tr>
	<td height="40">
		<label id="emailmsg" for="text">
			<?php echo JText::_( 'Message' ); ?>:
		</label>
	</td>
	<td>
    <textarea name="text" id="text"cols="40" rows="3"></textarea>
	</td>
</tr>
<tr>
	<td colspan="2" height="40">
<input type="checkbox" name="email_copy" id="contact_email_copy" value="1"  />

				<label for="contact_email_copy">
					<?php echo JText::_( 'Send me a copy' ); ?>
				</label>
	</td>
</tr>               
</table>
  <div align="center" style="margin-bottom:20px;">
 
	<button class="button validate" type="submit"><?php echo JText::_('Send'); ?></button>
    </div>
    <input type="hidden" name="option" value="com_properties" />
    <input type="hidden" name="view" value="property" />
	<input type="hidden" name="task" value="enviar_consulta" />
    <input type="hidden" name="id" value="<?php echo $row->id_Product;?>" />
    <input type="hidden" name="agent_id" value="<?php echo $row->agent_id;?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
</div>




<?php 
}/*Final ActivarContactar*/





if($ActivarReservas == 1){

if($ActivarTabs == 1){
echo $pane->endPanel();
echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Reserve').'" title="'.JText::_('Reserve').'" src="components/com_properties/includes/img/reservar.png" />', 'panel4' );
}
?>


<div id="calendarios" >

<form action="<?php echo JRoute::_( 'index.php' ); ?>" name="josFormCal" class="formCalendario" id="josFormCal" method="post" >
<input type="hidden" name="linkid" value="<?php echo JRequest::getVar('id'); ?>" />
<input type="hidden" name="linktypeid" value="<?php echo JRequest::getVar('tid'); ?>" />
<input type="hidden" name="linkcatid" value="<?php echo JRequest::getVar('cid'); ?>" />
<p></p>
<div class="calendario" style="float:left;padding-left:5px;">      
      <p class="lastup"></p>
 </div>
<div class="calendario" style=" float:right; padding-right:5px;width:200px" >  

      <label for="sd"><?php echo JText::_('Desde'); ?> : </label>
      
      <?php echo JHTML::_('calendar', $this->datos->fecha, 'fechaD', 'fechaD', '%Y-%m-%d', array('class'=>'inputbox2', 'size'=>'20',  'maxlength'=>'19')); ?>


      <p></p>
      <label for="ed"><?php echo JText::_('Hasta'); ?> : </label>
      
      <?php echo JHTML::_('calendar', $this->datos->fecha, 'fechaA', 'fechaA', '%Y-%m-%d', array('class'=>'inputbox2', 'size'=>'20',  'maxlength'=>'19')); ?>



      <p class="lastup"></p>
        
    <input type="hidden" name="option" value="com_properties" />

    <input type="hidden" name="layout" value="default_reservation" />
	<input type="hidden" name="task" value="send_reservation" />
    <input type="hidden" name="id" value="<?php echo $row->id;?>" />
    <input type="hidden" name="name" value="<?php echo $row->name;?>" />
  <div align="center" style="margin:20px;">  
  <button class="button validate" type="submit"><?php echo JText::_('Reservar'); ?></button> 
  </div>        
   </div>  
<div style="clear: both;"></div>
</form>
 </div>
<?php 
}/*Final if ActivarReservas*/


if($ActivarMapa == 1){

if($ActivarTabs == 1){
echo $pane->endPanel();

//$ruta= JURI::base().'index.php?option=com_properties&view=property&task=mapa&tmpl=component&id='.$row->id_Product;
echo $pane->startPanel( '<span class="image"><a href="#" onclick="recargarMapa();"><img class="editlinktip hasTip" width="20px" alt="'.JText::_('Map').'" title="'.JText::_('Map').'" src="components/com_properties/includes/img/mapa.png" /></a></span>', 'panel5' );
//echo $pane->startPanel( '<img width="20px" alt="'.JText::_('Map').'" title="'.JText::_('Map').'" src="components/com_properties/includes/img/mapa.png" />&nbsp;'.JText::_('Map'), 'panel4' );
}



//echo $pane->startPanel( '<img src="components/com_properties/includes/img/mapa.png" />', 'panel5' );
?>

<?php
/*
$params = &JComponentHelper::getParams( 'com_properties' );
$apikey=$params->get( 'apikey' );
$distancia=$params->get( 'distancia' )+2;

*/

$apikey=$params->get('apikey');
$distancia=$params->get('distancia');
$lat = $row->lat;
$lng = $row->lng;


?>


<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $apikey;?>"
      type="text/javascript"></script> 
 
 <script type="text/javascript"> 
  function load() { 
  <!--    if (GBrowserIsCompatible()) { -->
        var map = new GMap2(document.getElementById("map")); 
        map.setCenter(new GLatLng(<?php echo $lat;?>, <?php echo $lng;?>), <?php echo $distancia;?>);
		map.addControl(new GSmallMapControl());
		var marker = new GMarker(new GLatLng(<?php echo $lat;?>, <?php echo $lng;?>));
		map.addOverlay(marker);		
		}
		
  <!--  }--> 
 function recargarMapa() {
setTimeout("load()",50)
}
</script> 



<br />
<div align="center" style="float:left; text-align:center; width: 480px; height: 480px; overflow:hidden; padding-top: 30px; ">
<div id="map" style="width:480px; height:480px;"></div>
</div>
<div style="clear: both;"></div>

<?php 

?>

<!--[if lte IE 8]>
<script type="text/javascript">

</script>
<!--[else]>
<script type="text/javascript">

</script>
<![endif]-->

<script type='text/javascript' src='components/com_properties/includes/player/swfobject.js'></script>
<script type='text/javascript'>
function playFlv(file)
{
  var so = new SWFObject('components/com_properties/includes/player/player.swf','mpl','400','300','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file',"../../../../images/properties/"+file);
  so.write('mediaspace');
}
function playWmv(file)
{
	alert(file);
	var mediaspace = document.getElementById("mediaspace");
	mediaspace.innerHTML = "<embed autostart=\"1\" type=\"application/x-mplayer2\""+ 
	"src=\"images/properties/"+file+"\""+ 
		"name=\"MediaPlayer\" width=400 height=300></embed>";
}
</script>


<?php
if($ActivarTabs == 1){
echo $pane->endPanel();/*Final if ActivarMapa*/

echo $pane->startPanel( '<img class="editlinktip hasTip" alt="'.JText::_('Video').
'" title="'.JText::_('Video').'" src="components/com_properties/includes/img/video.png" />', 'panel6' );
$ext = end(explode(".",$row->video));

if(empty($row->video) || ($ext != "flv" && $ext!="wmv"))
{
	echo "<center><font color=red>Video unavaiable</font></center>";
}
else
{
	//$destino_imagen = JPATH_SITE.DS.'images'.DS.'properties'.DS;
	echo "<div id=\"mediaspace\"style=\"text-align:center;\"></div>";
	if($ext == "flv")
	{
		echo "<script>playFlv('".$row->video."')</script>";
	}
	if($ext == "wmv")
	{
		echo "<script>playWmv('".$row->video."')</script>";
	}
}

echo $pane->endPanel();

}
}



if($ActivarTabs == 1){
echo $pane->endPane();
}
?>
